package me.seu.demo.test.time;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;

import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * DateTimeOne
 *
 *
 * @since 2021/6/26 15:52
 */
@Slf4j
public class DateTimeOne {

    public static void main(String[] args) {
        Date nowDate = new Date();
        System.out.println(DateFormatUtils.format(nowDate, "yyyy-MM-dd HH:mm:ss"));
        Date sDate = DateUtils.truncate(nowDate, Calendar.SECOND);
        Date mDate = DateUtils.truncate(nowDate, Calendar.MINUTE);
        Date hDate = DateUtils.truncate(nowDate, Calendar.HOUR);
        Date h2Date = DateUtils.truncate(nowDate, Calendar.HOUR_OF_DAY);
        System.out.println(DateFormatUtils.format(sDate, "yyyy-MM-dd HH:mm:ss"));
        System.out.println(DateFormatUtils.format(mDate, "yyyy-MM-dd HH:mm:ss"));
        System.out.println(DateFormatUtils.format(hDate, "yyyy-MM-dd HH:mm:ss"));
        System.out.println(DateFormatUtils.format(h2Date, "yyyy-MM-dd HH:mm:ss"));

        List<String> list =  JSON.parseArray("[\"comm_device_test_0001\",\"comm_device_test_0002\"]", String.class);
        System.out.println(list.toString());
    }

}
